package com.food.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.food.pojo.Comments;
import com.food.result.Result;
import com.food.service.CommentsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "美食评论接口")
@CrossOrigin("*")
@RestController
@RequestMapping("/api/comments")
public class CommentsController {
    @Autowired
    private CommentsService commentsService;

    /**
     * 查询三条评论
     */
    @ApiOperation(value = "查询三条评论")
    @GetMapping("/select/limit/3")
    public Result selectLimit3() {
        return Result.ok(commentsService.selectLimit3());
    }

    /**
     * 查询个人评论
     */
    @ApiOperation(value = "查询个人下所有评论")
    @GetMapping("/select/limit/all/{userId}")
    public Result selectLimitAll(@PathVariable Integer userId) {
        return Result.ok(commentsService.selectLimitAll(userId));
    }

    /**
     * 插入评论
     */
    @ApiOperation(value = "插入评论")
    @PutMapping("/add/comment")
    public Result insertComments(@RequestBody Comments comments) {
        return Result.ok(commentsService.insertCommentByCommentRecord(comments));
    }

}
